﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DeviceInfoManage.BusinessLogicLayer;

public partial class ErrTypeManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["adminUserName"] == null)
            {
                Response.Redirect("login.aspx");
            }
        }
    }
    protected void Btn_Add_Click(object sender, EventArgs e)
    {
        /*添加新的设备类别*/
        string ErrTypeName = this.txtErrTypeName.Text;
        if (string.IsNullOrEmpty(ErrTypeName))
        {
            Response.Write("<script>alert('故障类别名称信息不能为空!');location.href=location.href;</script>");
        }
        else
        {
            ErrType errType = new ErrType();
            if (errType.AddErrType(ErrTypeName))
                Response.Write("<script>alert('故障类别信息添加成功!');location.href='ErrTypeManage.aspx';</script>");
            else
                Response.Write("<script>alert('" + errType.ErrMessage + "');</script>");
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标选择某行时变颜色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00ffee';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
        }
    }
}
